<?php
/**
 * Creater: 李青林
 * Date Time : 2018/8/22 19:15
 */

namespace App\Http\Models;


class StatisticsUser extends BaseModel
{
    protected $table = 'statistics_user';
    protected $guarded = [];

    /**
     * creater:lqr
     * 更新用户统计放单个数数据
     * @return mixed
     */
    public static function updateOrderNum()
    {
        $model = self::first();
        if (!$model) {
            $model = new StatisticsUser();
            $model->all_number = 1;
            $model->order_user = 1;
            $model->zreo_integral_user = 0;
            $model->order_permissions = 0;
            $model->is_auth = 0;
        } else {
            $model->increment('order_user', 1);
        }
        return $model->save();
    }

    /**
     * 增加0积分用户
     * $type   0 增加积分扣完用户,1 降低积分扣完用户
     * @return mixed
     */
    public static function addZeroInergralUser($type=0)
    {
        $model = self::first();
        if ($type==0){
            $model->increment('zreo_integral_user');
        }else{
            $model->decrement('zreo_integral_user');
        }
        return $model->save();
    }

    /**
     * 增加放单权限用户
     * @return mixed
     */
    public static function addOrderPermissionsUser()
    {
        $model = self::first();
        $model->increment('order_permissions');
        $model->decrement('order_apply');
        return $model->save();
    }

    /**
     * 增加用户认证数量
     * @return mixed
     */
    public static function addUserAuth()
    {
        $model = self::first();
        $model->increment('is_auth');
        return $model->save();
    }

    /**
     * 增加注册用户
     * @return mixed
     */
    public static function addRegisterUser()
    {
        $model = self::first();
        $model->increment('all_number');
        return $model->save();
    }

    /**
     * 增加放单申请用户
     * @return mixed
     */
    public static function addOrderApplyUser()
    {
        $model = self::first();
        $model->increment('order_apply');
        return $model->save();
    }
    /**
     * 降低放单申请用户
     * @return mixed
     */
    public static function decOrderApplyUser()
    {
        $model = self::first();
        $model->decrement('order_apply');
        return $model->save();
    }

}